<style type="text/css">
a {
	cursor: pointer;
}
.close {
	margin-right: 5px;
}
#modal input.size, #modal input.memo, .memo input, .sizenum input.size  {
	width: 100px;
	margin: 0 0 2px 5px;
	padding:4px;
}
#modal input.num, .sizenum input.num   {
	width: 40px;
	margin: 0 0 2px 5px;
	padding:4px;
}
#modal .row {
	padding: 12px;
}
.memo input {
	
}
</style>
<div class="pageheader">
	<h2>
		<i class="fa fa-pencil-square"></i>日志管理
	</h2>
	<div class="breadcrumb-wrapper">
		<span class="label">你所在的位置：</span>
		<ol class="breadcrumb">
			<li><a href="/index">ERP管理系统</a></li>
			<li>日志管理</li>
			<li class="active">每日报货</li>
		</ol>
	</div>
</div>
<div class="contentpanel">
	<div class="main">
        <?php if ($this->msg):?>
        <div class="form-group">
            <span class="label label-warning">
            <?php if($this->msg == 'success'){echo '操作成功';}else{echo '操作失败';}?>
            </span>
        </div>
        <?php endif;?>  
		<div class="form-inline search" style="margin-bottom: 10px;">
			<div class="form-group title">
				<input placeholder="产品名称" type="text" name="title" class="form-control">
			</div>
			<a class="btn btn-primary search-btn">搜索</a>
			<a class="btn btn-warning modify-btn confirm">确定修改</a>
		</div>
		<form id="add-form" method="post" action="/log/dailybaohuo">
			<div class="table-responsive">
			    <table class="table table-bordered table-hover">
				    <thead>
					    <tr>
						    <th>SKU</th>
					    	<th>产品名称</th>
						    <th>尺码与数量</th>
						    <th>备注</th>
					    </tr>
				    </thead>
				    <tbody>

    				</tbody>
	    		</table>
		    </div>
		    <input class="btn btn-primary" type="submit" value="生成报货进仓">
		</form>
	</div>
</div>
<div id="modal" class="modal" tabindex="-1" style="display: none;">
	<div class="modal-dialog modal-photo-viewer">
		<div class="modal-content" style="overflow-y:scroll;overflow-x: hidden;">
			<div class="row">
		        <div class="table-responsive">
			        <table class="table table-bordered table-hover table-warning">
			        	<thead>
					        <tr>
						        <th><input checked="checked" type="checkbox" name="checkall">&nbsp;&nbsp;全选</th>
						        <th>SKU</th>
						        <th>产品名称</th>
						        <th>尺码与数量</th>
						        <th>备注</th>
					        </tr>
				        </thead>
				        <tbody>
				        </tbody>
			        </table>
                    <input class="confirm btn btn-primary" type="button" value="确定">
                    <input class="cancel btn btn-warning" type="button" value="取消">
		        </div>
			</div>
		</div>
	</div>
</div>
<div class="in"></div>
<script type="text/javascript">
$(document).ready(function(){
	$('.search .search-btn').click(function(){
		var stitle = $('.title input').val();
		stitle = $.trim(stitle);//去掉空格
		if(stitle == ''){
			
		}else{
			$.post("/log/loadsku", {title:stitle},
				function(data){
				    if(data.flag == 'success'){
						$(".modal").show();
						$(".in").addClass("modal-backdrop");
					    $(".modal tbody").html(data.content);
				    }
			    },'json'
		    );
		}
	});
	$('#modal .confirm').click(function(){
		$(".modal").hide();
		$(".in").removeClass("modal-backdrop");
		$("input[name='isprint[]']").each(function (j) {
			if($(this).is(":checked")){
				$(this).parent(".input-select").remove();
			    $("form tbody").append($("#modal tbody tr:eq("+j+")").clone());
			}
	    });
	    $("#modal th input").attr("checked","checked");
	});
	$('#modal .cancel').click(function(){
		$(".modal").hide();
		$(".in").removeClass("modal-backdrop");
	});
	$(".modify-btn").click(function(){
		if($(this).hasClass("confirm")){
			$("#add-form .sizenum").each(function(){
				var $td = $(this);
				var str = '';
				$(this).children("div").each(function(){
					$(this).children("input").hide();
					if($(this).children(".num").val()==0){
					}else{
						str = str+$(this).children(".size").val()+"/"+$(this).children(".num").val()+";";
					}
				});
				$td.children(".text").html(str);
			});
			$(".modify-btn").html("修改数量");
			$(".modify-btn").removeClass("confirm").addClass("change");
		}else{
			$("#add-form .sizenum").each(function(){
				var $td = $(this);
				$(this).children("div").each(function(){
					$(this).children("input").show();
				});
				$td.children(".text").html('');
			});
			$(".modify-btn").html("确定修改");
			$(".modify-btn").removeClass("change").addClass("confirm");
		}
	});
});
</script>